<?php
namespace App\Http\Resources\Trade\Supply;

use App\Http\Resources\ResourceCollection;

class RejectDetailResource extends ResourceCollection
{

    /**
     * Transform the resource into an array.
     *
     * @param \Illuminate\Http\Request $request            
     * @return array
     */
    public function toArray($request)
    {
        $data = $this->collection->shift();
        return self::makeDataDecode($data);
    }

    /**
     * 制作使用数据（一条）
     */
    public static function makeDataDecode($data)
    {
        // 驳回标签
        if (isset($data['reject']) && ! empty($data['reject'])) {
            $data['reject'] = json_decode($data['reject'], true);
        } else {
            $data['reject'] = array();
        }
        return $data;
    }
}
